<?
//检查是否有权限
//include_once("../../../common/modules/checkA.php");
//测试地址
//http://t.yitong.com/front/employee_center/view/member_creat_notice.php?athloncode=circledesign&message_nid=1001

//获取根目录的系统设置文件
include_once("../../../config.php");
include_once("../../connection.php");

$seo['description'] = "";
$seo['keyword']     = "";
$seo['title']       = "天宫信息科技";



include_once("../../../config/site_theme_config.php");
$_SESSION['database'] = $_unit[$_REQUEST['athloncode']]['database'];
//只在登录的时候需要再引入一次。登录之后就会产生session，会在config中引入
include_once (ROOT_PATH_."/front/connection.php");



update_exists('`'.$_unit[$_REQUEST['athloncode']]['database'].'`.`'.$table_Prefix."member_contact_log`" , '`content_translate`' , 1);//检查表是否有这个字段  如果没有自动生




include_once(ROOT_PATH_."/api/translate/bdsdk.php");//导入百度的sdk



//根据查找
$message = select_one_line_all_items($table_prefix . "member_contact_log", "nid = '" . $_REQUEST['message_nid'] . "'");
$member  = select_one_line_all_items($table_prefix . "member", "nid = '" . $message['membernid'] . "'");
$unit    = select_one_line_all_items($table_prefix . "unit", "nid = '" . $message['unitnid'] . "'");


$message['content']=str_ireplace(",","，",$message['content']);
$message['content']=str_ireplace(".","。",$message['content']);



//翻译留言，同同时
if(!$message['content_translate'])
{
    $_result_json=translate(addslashes($message['content']),'auto',"zh");

    //echo $_result_json['trans_result'][0]['dst'];
    //print_r2($_result_json);
    foreach ($_result_json['trans_result'] as $k=>$v)
    {
        $_trans_content['ai_content_translate']=$_trans_content['ai_content_translate'].$v['dst'];
    }

    if(!$_trans_content['ai_content_translate'])
    {
        $_trans_content['ai_content_translate']="";
    }
    //print_r2($_result_json);

    $_update_trans=update_date($table_prefix."member_contact_log",$_trans_content,"nid",$message['nid']);
    $query = mysql_query($_update_trans) or die (mysql_error().$_update_trans);
}

//print_r2($_result_json);

//获取IP地址，查看地理位置
$_ipinfo = api_ip_info($message['ip']);
$country = $_ipinfo['data'][0]['location'];


if(!$message['content_translate'])
{
    $message['content_translate']=$_trans_content['ai_content_translate'];
}



//谁观看，就给谁。如果有所属的话，就弹出另外的页面提示。
//如果这个已经被领取，不是是否本人都提示通知失效，已经被领取，并且根据公布情况展示。




//设置业务员，用于跟进客户
$employee=select_lines_all_items($table_prefix."employee","","nid >0 and status = '在职'","");


//统计各自用户跟进的客户
foreach ($employee as $k=>$v)
{
    $employee_static[$k]['name']=$v['name'];
    $employee_static[$k]['sum']=count_by_item($table_prefix."member","agentnid = '".$v['nid']."' ");
    $employee_static[$k]['nid']=$v['nid'];
}
sort($employee_static);


$data['title']="新留言信息";
?>
